package com.sch.wanandroid.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.load
import com.sch.wanandroid.R
import com.sch.wanandroid.entity.BannerBean
import com.youth.banner.adapter.BannerAdapter

/**
 * Created by Sch.
 * Date: 2020/12/17
 * description:
 */
class HomeBannerAdapter(datas: List<BannerBean>) :
    BannerAdapter<BannerBean, HomeBannerAdapter.BannerViewHolder>(datas) {

    class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val imageView: ImageView = view.findViewById(R.id.iv_banner)
    }

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        val view =
            LayoutInflater.from(parent!!.context).inflate(R.layout.item_banner, parent, false)
        return BannerViewHolder(view)
    }

    override fun onBindView(
        holder: BannerViewHolder?,
        data: BannerBean?,
        position: Int,
        size: Int
    ) {
        holder?.imageView?.load(data?.imagePath)
    }
}